<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*
        ① 如果try报错，自报错位置开始，try的后续代码停止执行，同是执行catch代码
        ② 如果是语法错误，无法通过 catch 捕捉
     */
      try {
        //if
        console.log("hello try1");
        JSON.parse('{"a":1,}'); //报错
        console.log("hello try2");
      } catch (e) {
        //else 报错才会执行
        console.log("hello catch");
      }
    </script>
  </body>
</html>
